package com.springboot.utils;

import com.springboot.config.primary.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * ScheduledTasks
 * 定时任务
 * @author jlicc
 * @create 2017-03-17-11:55
 **/
@Component
public class ScheduledTasks {

    @Autowired
    private UserRepository userRepository;

    private static final SimpleDateFormat dateFormat = new SimpleDateFormat("YYYY-MM-DD HH:mm:ss");

    //@Scheduled(fixedRate = 10000)
    public void reportCurrentTime() throws Exception{
        System.out.println("现在时间：" + dateFormat.format(new Date()));
        System.out.println("user：" + userRepository.findAll().size());
    }
}
